Socket
Socket
Sign inDemoInstall

readimage

Package Overview
Dependencies
5
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    readimage

Read an image (jpg, png, gif) into memory in the same format.


Version published
Maintainers
1
Install size
0.982 MB
Created

Readme

Source

readimage

NPM

Read an image into memory converting from whatever format it is in to a consistent set of RGBA frames independent on input format.

Why? Because image formats are a pain to worry about.

How fast is it? Not really sure. I don't need it to be fast.

How robust is it? Not really sure, if you have issues please file them!


var fs = require("fs")
var readimage = require("readimage")

var filedata = fs.readFileSync("cat.png")

readimage(filedata, function (err, image) {
  if (err) {
    console.log("failed to parse the image")
    console.log(err)
  }
  console.log(image)
})

API

require("readimage")(imageBuffer, callback)

Read a buffer containing an image in PNG, GIF, or JPG format into a consistent RGBA format.

FORMAT

height, width, and an array of sequential frames. Non-animated images will have a single frame.

{
  height: 100, // pixels
  width: 100, // pixels
  frames: [
    {
      data: ... // RGBA buffer
      delay: 100 // milliseconds before switching to next frame. OPTIONAL
    },
    {
      data: ...
      delay: 10
    }
  ]
}

LICENSE

MIT

Keywords

FAQs

Last updated on 01 Sep 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc